package com.wl2o2o.collection.arrays;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * @Author <a href="https://github.com/wl2o2o">程序员CSGUIDER</a>
 * @From <a href="https://wl2o2o.github.io">CSGUIDER博客</a>
 * @CreateTime 2024/3/25
 */
public class Interator {
    public static void main(String[] args) {
        // 创建集合
        ArrayList<String> list = new ArrayList<String>();
        list.add("weilei");
        list.add("javab");
        list.add("javab");

        list.add("lanqiaobei");
        list.add("jiayou");

        //获取迭代器
        Iterator<String> it = list.iterator();
        //循环遍历输出
        while (it.hasNext()) {
            String i = it.next();
            if (i == "weilei") {
                it.remove();
            }
            System.out.print(it.next() + " ");
        }
    }
}
